/*  1:   */ package org.jetbrains.generate.tostring.config;
/*  2:   */ 
/*  3:   */

import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiMethod;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.generate.tostring.psi.PsiAdapter;

/*  4:   */
/*  5:   */
/*  6:   */
/*  7:   */
/*  8:   */ 
/*  9:   */ public class InsertAfterEqualsHashCodeStrategy
/* 10:   */   implements InsertNewMethodStrategy
/* 11:   */ {
/* 12:29 */   private static final InsertAfterEqualsHashCodeStrategy a = new InsertAfterEqualsHashCodeStrategy();
/* 13:   */   
/* 14:   */   public static InsertAfterEqualsHashCodeStrategy getInstance()
/* 15:   */   {
/* 16:34 */     return a;
/* 17:   */   }
/* 18:   */   
/* 19:   */   public PsiMethod insertNewMethod(PsiClass paramPsiClass, @NotNull PsiMethod paramPsiMethod, Editor paramEditor)
/* 20:   */   {
/* 21:38 */     if (paramPsiMethod == null) {
/* 22:38 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "1", "org/jetbrains/generate/tostring/config/InsertAfterEqualsHashCodeStrategy", "insertNewMethod" }));
/* 23:   */     }
/* 24:38 */     PsiMethod localPsiMethod1 = PsiAdapter.findHashCodeMethod(paramPsiClass);
/* 25:39 */     PsiMethod localPsiMethod2 = PsiAdapter.findEqualsMethod(paramPsiClass);
/* 26:   */     PsiMethod localPsiMethod3;
/* 27:43 */     if ((localPsiMethod2 != null) && (localPsiMethod1 != null))
/* 28:   */     {
/* 29:44 */       if (localPsiMethod2.getTextOffset() > localPsiMethod1.getTextOffset()) {
/* 30:45 */         localPsiMethod3 = localPsiMethod2;
/* 31:   */       } else {
/* 32:47 */         localPsiMethod3 = localPsiMethod1;
/* 33:   */       }
/* 34:   */     }
/* 35:   */     else {
/* 36:50 */       localPsiMethod3 = localPsiMethod1 != null ? localPsiMethod1 : localPsiMethod2;
/* 37:   */     }
/* 38:53 */     if (localPsiMethod3 != null) {
/* 39:55 */       paramPsiMethod = (PsiMethod)paramPsiClass.addAfter(paramPsiMethod, localPsiMethod3);
/* 40:   */     } else {
/* 41:58 */       paramPsiMethod = InsertAtCaretStrategy.getInstance().insertNewMethod(paramPsiClass, paramPsiMethod, paramEditor);
/* 42:   */     }
/* 43:61 */     return paramPsiMethod;
/* 44:   */   }
/* 45:   */   
/* 46:   */   public String toString()
/* 47:   */   {
/* 48:65 */     return "After equals/hashCode";
/* 49:   */   }
/* 50:   */ }



/* Location:           E:\idea\

 * Qualified Name:     org.jetbrains.generate.tostring.config.InsertAfterEqualsHashCodeStrategy

 * JD-Core Version:    0.7.0.1

 */